<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />

<div class="t_bar">
    <span class="color_red">*</span>种子资金、孵化资金设立情况表
</div>
<table class="t_css" id="table_03" style="text-align: center;">
    <col style="width: 20%" />
    <col style="width: 16%" />
    <col style="width: 16%" />
    <col style="width: 16%" />
    <col style="width: 16%" />
    <col style="width: 16%" />
    <tr>
        <td rowspan="3">
            资金及来源<br />（万元）
        </td>
        <td rowspan="2">设立时间</td>
        <td rowspan="2">
            资金总额<br />（万元）
        </td>
        <td colspan="3">其中</td>
    </tr>
    <tr>
        <td>政府拨款</td>
        <td>自有资金</td>
        <td>其它来源</td>
    </tr>
    <tr>
        <c:set var="establish_data">
            <x:out select="$xmlData/data/proposal/establish_data" />
        </c:set>
        <td>
            <cpt:date id="establish_data" name="proposal/establish_data" value="${establish_data }"
                className="required data" label="资金及来源-->设立时间" size="9"></cpt:date>
        </td>
        <td>
            <input name="proposal/total_funding" id="total_funding"
                value="<x:out select="$xmlData/data/proposal/total_funding"/>" class="gray"
                readonly="readonly" style="text-align: right; width: 80%;" />
        </td>
        <td>
            <input name="proposal/status1_funding" id="status1_funding"
                onfocus="InitInput.setNumber(this,9,2,2)"
                value="<x:out select="$xmlData/data/proposal/status1_funding"/>" class="required"
                label="资金及来源-->其中-->政府拨款" style="text-align: right; width: 80%;" />
        </td>
        <td>
            <input name="proposal/status2_funding" id="status2_funding"
                onfocus="InitInput.setNumber(this,9,2,2)"
                value="<x:out select="$xmlData/data/proposal/status2_funding"/>" class="required"
                label="资金及来源-->其中-->自有资金" style="text-align: right; width: 80%;" />
        </td>
        <td>
            <input name="proposal/status3_funding" id="status3_funding"
                onfocus="InitInput.setNumber(this,9,2,2)"
                value="<x:out select="$xmlData/data/proposal/status3_funding"/>" class="required"
                label="资金及来源-->其中-->其它来源" style="text-align: right; width: 80%;" />
        </td>
    </tr>
</table>



<div class="t_bar">
    <span class="color_red">*</span>种子资金、孵化资金支持入驻创业团队或初创期小微企业项目情况
</div>
<table id="eq_table4" class="t_css">
    <col style="width: 5%" />
    <col style="width: 5%" />
    <col style="width: 32%" />
    <col style="width: 32%" />
    <col style="width: 10%" />
    <col style="width: 16%" />
    <thead>
        <tr style="border: 1px solid #B7D1E6">
            <th class="TblHead" align="center">选择</th>
            <th class="TblHead" align="center">序号</th>
            <th class="TblHead" align="center">项目名称</th>
            <th class="TblHead" align="center">项目单位</th>
            <th class="TblHead" align="center">支持年度</th>
            <th class="TblHead" align="center">支持额度<br>（万元）
            </th>
        </tr>
    </thead>
    <tbody id="tab">
        <tr style="display: none;">
            <td align="center">
                <input type="radio" style="border: 0px; background-color: white;"
                    class="radiobutton" name="selMileStones">
            </td>
            <td align="center">
                <span name="prj_situations|prj_situation[0]@seq_no">[index]</span>
            </td>
            <td align="center">
                <input name="prj_situations|prj_situation[0]|basic_info|prj_name" style="width: 80%"
                    label="项目名称" type="text" class="input_text required" value="" maxlength="20" />
            </td>
            <td align="center">
                <input name="prj_situations|prj_situation[0]|basic_info|prj_unit" style="width: 80%"
                    label="项目单位" type="text" class="input_text required" value="" maxlength="50" />
            </td>
            <td align="center">
                <input name="prj_situations|prj_situation[0]|basic_info|support_year"
                    style="width: 80%; text-align: right;" label="支持年度"
                    onfocus="InitInput.setNumber(this,4,0,0)" type="text"
                    class="input_text required year" value="" />
            </td>
            <td align="center">
                <input name="prj_situations|prj_situation[0]|basic_info|support_funding"
                    id="support_funding[0]" style="width: 80%; text-align: right;" label="支持额度"
                    onfocus="InitInput.setNumber(this,9,2,2);" type="text"
                    onchange="setTotalFunding();" class="input_text required" value="" />
            </td>
        </tr>


        <c:set value="0" var="index" scope="page" />
        <x:forEach select="$xmlData/data/prj_situations/prj_situation" var="prj_situation">

            <c:choose>
                <c:when test="${index<10}">
                    <c:set value="0" var="flag" scope="page" />
                </c:when>
                <c:otherwise>
                    <c:set value="" var="flag" scope="page" />
                </c:otherwise>
            </c:choose>
            <tr>
                <td align="center">
                    <input type="radio" style="border: 0px; background-color: white;"
                        class="radiobutton" name="selMileStones">
                </td>
                <td align="center">
                    <span name="prj_situations/prj_situation[${flag}${index}]@seq_no"><x:out
                            select="$prj_situation/@seq_no" /></span>
                </td>
                <td align="center">
                    <input name="prj_situations/prj_situation[${flag}${index}]/basic_info/prj_name"
                        label="项目名称" style="width: 80%" type="text" class="input_text required"
                        value="<x:out select="$prj_situation/basic_info/prj_name"/>" maxlength="20" />
                </td>
                <td align="center">
                    <input name="prj_situations/prj_situation[${flag}${index}]/basic_info/prj_unit"
                        label="项目单位" style="width: 80%" type="text" class="input_text required"
                        value="<x:out select="$prj_situation/basic_info/prj_unit"/>" maxlength="50" />
                </td>
                <td align="center">
                    <input
                        name="prj_situations/prj_situation[${flag}${index}]/basic_info/support_year"
                        style="width: 80%; text-align: right;" label="支持年度"
                        onfocus="InitInput.setNumber(this,4,0,0)" type="text"
                        class="input_text required year"
                        value="<x:out select="$prj_situation/basic_info/support_year"/>" />
                </td>
                <td align="center">
                    <input
                        name="prj_situations/prj_situation[${flag}${index}]/basic_info/support_funding"
                        id="support_funding[${flag}${index}]" style="width: 80%; text-align: right;"
                        label="支持额度" onfocus="InitInput.setNumber(this,9,2,2);"
                        type="text" class="input_text required" onchange="setTotalFunding();"
                        value="<x:out select="$prj_situation/basic_info/support_funding"/>" />
                </td>
            </tr>
            <c:set value="${index+1}" var="index" scope="page" />
        </x:forEach>
    </tbody>
</table>
<table class="t_css">
    <col style="width: 84%" />
    <col style="width: 16%" />
    <tr>
        <td align="center">合计</td>
        <td align="center">
            <input name="proposal/subport_total_funding" id="subport_total_funding"
                value="<x:out select="$xmlData/data/proposal/subport_total_funding"/>" class="gray"
                readonly="readonly" style="text-align: right; width: 80%;" />
        </td>
    </tr>
</table>
<table width="98%" align="center">
    <tr>
        <td>
            <input class="button_02" name="cmdAddbefore" type=button value="添加"
                onclick="if(checkTabLimit('eq_table4',999,'种子资金、孵化资金支持入驻创业团队或初创期小微企业项目情况内容最多只能填写999条')){addNewRow('eq_table4');showDateTag('eq_table4');}try{top.resizeFrame();}catch(e){};">
            <input class="button_02" name="cmdMovePrev" type=button value="上移"
                onclick="movePrev('eq_table4','selMileStones');">
            <input class="button_02" name="cmdMoveNext" type=button value="下移"
                onclick="moveNext('eq_table4','selMileStones');">
            <input class="button_02" name="cmddel" type=button value="删除"
                onclick="deleteSelectedRow('eq_table4','种子资金、孵化资金支持入驻创业团队或初创期小微企业项目情况');setTotalFunding();">
        </td>
    </tr>
</table>
<script>
	$('#status1_funding,#status2_funding,#status3_funding').change(function() {
		getTotalCount("", "status1_funding,status2_funding,status3_funding",
				"total_funding", true);
	});
    
	function setTotalFunding(){
		var totalFunding = 0;
        $("#eq_table4 tr:gt(1)").each(function() {
            var funding = $(this).find("td:eq(5) input").val()||0;
            totalFunding += parseFloat(funding);
        });
        $("#subport_total_funding").val(parseFloat(totalFunding).toFixed(2));
	}
	/**
	 ----------------------by zk
	 参数prefix：公共的id开头
	 参数count：需要加的数的id结尾     以,分割
	 参数total：总数id结尾
	 参数isDeciaml：是否为小数 默认为false
	 */
	function getTotalCount(prefix, count, total, isDecimal) {
		var defaultIsDecimal = false;//默认为整数
		if (isDecimal == null) {
			isDecimal = defaultIsDecimal;
		}
		var numStr = count.split(',');
		var totalCount = 0;//总数
		if (!isDecimal) {
			for ( var int = 0; int < numStr.length; int++) {
				var num = $('#' + prefix + numStr[int]).val();
				if (!$.isNumeric(num))
					num = "0";
				totalCount += parseInt(num);
			}
		} else {
			for ( var int = 0; int < numStr.length; int++) {
				var num = $('#' + prefix + numStr[int]).val();
				if (!$.isNumeric(num))
					num = "0";
				totalCount += parseFloat(num);
			}
			totalCount = ((totalCount / 100) * 100).toFixed(2);
		}
		$('#' + prefix + total).val(totalCount);
	}

	function initControlValue(objId) {
		
		var name = "";
		var obj = $("#" + objId);
		if (obj.is("select")) {
			name = obj.attr("name");
			obj.parent().children("input[name$='" + name + "_value'][type='hidden']").val(
					$("#" + objId).find("option:selected").val());
			$("#" + objId).parent().children("input[name$='" + name + "_name']").val(
					$("#" + objId).find("option:selected").text());
		}

		else if (obj.is(":radio")) {
			name = obj.attr("name");
			if (obj.is(":checked")) {//如果被选中
				//alert($("#"+objId).val());        
				obj.parents("table").find("input[name$='" + name + "_value'][type='hidden']").val(
						$("#" + objId).val());
				$("#" + objId).parent().children("input[name$='" + name + "_name']").val(
						$("#" + objId).next().text());
			} else {
				
				obj.parents("table").find("input[name$='" + name + "_value'][type='hidden']").val(
						"");
			}
		} else if (obj.is(":checkbox")) {
			name = obj.attr("name");
			if (obj.is(":checked"))//如果被选中
				obj.parent().find("input[name$='" + name + "_value'][type='hidden']").val(
						$("#" + objId).val());
			else
				obj.parent().find("input[name$='" + name + "_value'][type='hidden']").val("");
		} else {
			name = obj.attr("id");
			obj.parents("td").find("input[name$='" + name + "_name'][type='hidden']")
					.val(obj.val());
			obj.parents("td").find("input[name$='" + name + "_code'][type='hidden']").val(
					$("#" + objId + "_hideId").val());
		}
	}
</script>
